package com.example.lcpractice.thread;

import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger;

public class ThreadPoolDemo {
    private static final ExecutorService SERVICE =
            new ThreadPoolExecutor(10, 10,
                    60L, TimeUnit.SECONDS,
                    new ArrayBlockingQueue(10));

    public static void main(String[] args) {
        // 打印线程的名字
        System.out.println("main thread name:" + Thread.currentThread().getName());
        SERVICE.execute(() -> {
            System.out.println("Hello thread pool.");
            // 打印线程池里的线程的名字
            System.out.println("thread name:" + Thread.currentThread().getName());
        });
    }

}
